package org.dzq.designmode.proxy.cglibproxy;

import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;

/**
 * @ClassName: CglibFactory
 * @Package: org.dzq.designmode.proxy.cglibproxy
 * @author: 越
 * @date: 2023/6/17 15:11
 * @Description:
 */
public class CglibProxyFactory {

    public static Object getProxyByCglib(Class<?> clazz, MethodInterceptor methodInterceptor){
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(clazz);
        enhancer.setCallback(methodInterceptor);
        Object cglibProxyObject = enhancer.create();
        return cglibProxyObject;
    }
}
